﻿--资料中心
create table DocDir
(
	ID			int primary key ,
	[Name]		varchar(100) not null,
	UpperID		int not null,
	Path		varchar(100) not null,
	Depth		int not null,
	Orders		int ,
	CreatorID	int not null,
	CreatorName varchar(50),
	InputTime	datetime not null default getdate(),
	Remark		varchar(200)
)
insert into [docdir] ([ID],[Name],[UpperID],[Path],[Depth],[Orders],[CreatorID],[CreatorName],[InputTime],[Remark]) values  (1,'资料中心',0,',',0,0,-1,'系统管理员','2007-7-12 16:50:01','');
go
create table Document
(
	ID			int primary key ,
	[Name]		varchar(200) not null,
	DirID		int foreign key references DocDir(ID) on delete cascade,
	Content		varchar(5000),
	CreatorID	int not null,
	CreatorName varchar(50),
	InputTime	datetime  default getdate(),
	ClickCount	int default 0,
	DocSource	varchar(100),
	SerialNo	varchar(100),
	Remark		varchar(100)
)
go
create table DocAttach
(
	ID		   int primary key ,
	[Name]	   varchar(200) not null,
	BindID	   int foreign key references Document(ID) on delete cascade,
	Content	   image,
	Type	   varchar(100),
	[Size]	   int not null,	
	UploadTime datetime default getdate(),	
)
go
create table DocDirRight
(
	RightID   int,
	OwnerID	  int,
	BindID	  int foreign key references DocDir(ID) on delete cascade,
	OwnerType int
)
go
create table DocRight
(
	RightID   int,
	OwnerID   int,
	BindID	  int foreign key references Document(ID) on delete cascade,
	OwnerType int
)
go